﻿using System;
using System.Text;
using System.Runtime.Serialization;

namespace NetBay.Core.BusinessEntities.Workflow
{
    [DataContract]
    public class WorkflowDocument : WorkflowItem
    {

        private ItemType _itemsType = ItemType.Document;

        #region Properties

        /// <summary>
        /// Gets or sets the type of the item.
        /// </summary>
        /// <value>The type of the item.</value>
        public override ItemType ItemType
        {
            get
            {
                return _itemsType;
            }
            set
            {
                _itemsType = value;
            }
        }

        /// Get or set the DocumentId
        /// </summary>
        [DataMember]
        public long DocumentId { get; set; }

        /// <summary>
        /// Gets or sets the sender group id.
        /// </summary>
        /// <value>The sender group id.</value>
        [DataMember]
        public long SenderGroupId { get; set; }

        /// <summary>
        /// Gets or sets the name of the sender group.
        /// </summary>
        /// <value>The name of the sender group.</value>
        [DataMember]
        public string SenderGroupName { get; set; }

        /// <summary>
        /// Gets or sets the name of the sender group.
        /// </summary>
        /// <value>The name of the sender group.</value>
        [DataMember]
        public string AchievedBy { get; set; }

        /// <summary>
        /// document State  
        /// </summary>
        [DataMember]
        public WorkflowState DocumentStatus { get; set; }

        /// <summary>
        /// Gets or sets the document status label.
        /// </summary>
        /// <value>The document status label.</value>
        [DataMember]
        public string DocumentStatusLabel { get; set; }

        /// <summary>
        /// Get or set the FolderTypeIdentifier
        /// </summary>
        [DataMember]
        public long InstanceId { get; set; }

        /// <summary>
        /// Gets or sets the comment.
        /// </summary>
        /// <value>The comment.</value>
        [DataMember]
        public string Comment { get; set; }

        /// <summary>
        /// Gets or sets the group user id.
        /// </summary>
        /// <value>The group user id.</value>
        [DataMember]
        public long GroupUserId { get; set; }

        /// <summary>
        /// Gets or sets the created on.
        /// </summary>
        /// <value>The created on.</value>
        [DataMember]
        public DateTime CreatedOn { get; set; }

        /// <summary>
        /// Gets or sets the modified on.
        /// </summary>
        /// <value>The modified on.</value>
        [DataMember]
        public Nullable<DateTime> ModifiedOn { get; set; }

        /// <summary>
        /// Gets or sets the last action id.
        /// </summary>
        /// <value>The last action id.</value>
        [DataMember]
        public long LastActionId { get; set; }

        #endregion  

        #region Public functions

        /// <summary>
        /// Extend default description of class
        /// </summary>
        /// <returns>description of instance</returns>
        public override string ToString()
        {
            StringBuilder parameters = new StringBuilder("Identifier<", 4096);
            parameters.Append(Identifier); parameters.Append("> ");
            parameters.Append("DocumentId<"); parameters.Append(DocumentId); parameters.Append("> ");
            parameters.Append("DocumentState<"); parameters.Append(DocumentStatus); parameters.Append("> ");
            parameters.Append("InstanceId<"); parameters.Append(InstanceId); parameters.Append("> ");
            return parameters.ToString();
        }

        public override object Clone()
        {
            return this.MemberwiseClone();
        }

        #endregion

        #region Constructors
        
        public WorkflowDocument()
        {
        }

        public WorkflowDocument(long InstanceId)
        {
            this.InstanceId = InstanceId;
        }

        /// <summary>
        /// Only for error
        /// </summary>
        /// <param name="ErrorMessage"></param>
        public WorkflowDocument(string errorMessage, Exception applicationException = null)
            : base(errorMessage, applicationException)
        {
        }


        #endregion

    }
}
